home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
program
/
n_b_v203.zip
/
RINSTR.DMO
< prev
next >
Wrap
Text File
|
1996-07-04
|
2KB
|
50 lines
$if 0
┌──────────────────────────╖ PowerBASIC v3.20
┌──┤ DASoft ╟──────────────────────┬──────────────────╖
│ ├──────────────────────────╢ Copyright 1995 │ DATE: 1995-10-01 ╟─╖
│ │ FILE NAME RINSTR .DMO ║ by ╘════════════════─ ║ ║
│ │ ║ Don Schullian, Jr. ║ ║
│ ╘══════════════════════════╝ ║ ║
│ A license is hereby granted to the holder to use this source code in ║ ║
│ any program, commercial or otherwise, without receiving the express ║ ║
│ permission of the copyright holder and without paying any royalties, ║ ║
│ as long as this code is not distributed in any compilable format. ║ ║
│ IE: source code files, PowerBASIC Unit files, and printed listings ║ ║
╘═╤═════════════════════════════════════════════════════════════════════╝ ║
│ .................................... ║
╘═══════════════════════════════════════════════════════════════════════╝
$endif
'.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
$INCLUDE "DAS-NB01.INC"
COLOR 7, 0
CLS
? "┌─────────────────────────────────────────────────────────────────
? "│ fRINSTR%( Start%, ANY, Search$ )
? "├───────────────────────────────────────────────────────────────────
? "│ Reverse INSTR searches for the first occurrence of Search$ in ANY$
? "│ starting at the Start%th character and returns the MID$ position
? "│ of Search$ or ZERO if it is not found.
? "└───────────────────────────────────────────────────────────────────────
MAP A$$ * 30
A$$ = "THIS IS A RATHER LONG TEST 123"
S$ = "TH"
D$ = "Search for each occurrence of `"+ S$ + "` in `" + A$$ + "`"
REPLACE "`" WITH CHR$(34) IN D$
PRINT
PRINT D$
PRINT
DO
P% = fRINSTR% ( P%, A$$, S$ ) ' if P% = 0 then
IF P% > 0 THEN ' fRINSTR will start
PRINT USING$( "MIDpos: ## ", P%); MID$( A$$, P% ) ' at the end of A$$
DECR P%, 1 ' so you don't have
END IF ' to compute LEN(A$$)
IF INSTAT THEN EXIT LOOP '
LOOP UNTIL P% = 0